package com.sss.hloster0103;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Scanner;

public class TestURL {

	public static void main(String[] args) {
		URL tU = null;
		BufferedReader in = null;
		Scanner sc = new Scanner(System.in);
		System.out.println("请输入需要定位的URL地址：");
		String url = sc.next();
		System.out.println("请输入需要显示哪个页面标签元素的内容：");
		String iStr = sc.next();
		try {
			// 通过URL字符串创建URL对象
			tU = new URL(url);
			in = new BufferedReader(new InputStreamReader(tU.openStream()));
			String s;
			while ((s = in.readLine()) != null) {
				if (s.contains(iStr)) {
					System.out.println(s);
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}
